home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagg_m.zip / JOYSTICK.SWG / 0012_Joystick Testing.pas < prev    next >
Pascal/Delphi Source File  |  1994-05-25  |  2KB  |  109 lines

  1.  
  2. Program JoyTest;
  3.  
  4. uses
  5.    crt;
  6.  
  7. var
  8.    ch:char;
  9.    x1,y1,x2,y2:word;
  10.  
  11. Function JoyExist:boolean;
  12. var
  13.    temp:byte;
  14. begin
  15.    asm
  16.       mov ah,84h
  17.       mov dx,00h
  18.       int 15h
  19.       mov temp,al
  20.    end;
  21.    if temp=0 then JoyExist:=false
  22.    else JoyExist:=true;
  23. end;
  24.  
  25. Function JoyX:word;
  26. var
  27.    temp:word;
  28. begin
  29.    asm
  30.       mov ah,84h
  31.       mov dx,01h
  32.       int 15h
  33.       mov temp,ax
  34.    end;
  35.    JoyX:=temp;
  36. end;
  37.  
  38. Function JoyY:word;
  39. var
  40.    temp:word;
  41. begin
  42.    asm
  43.       mov ah,84h
  44.       mov dx,01h
  45.       int 15h
  46.       mov temp,bx
  47.    end;
  48.    JoyY:=temp;
  49. end;
  50.  
  51. Function JoyBtn1:boolean;
  52. var
  53.    temp:byte;
  54. begin
  55.    asm
  56.       mov ah,84h
  57.       mov dx,00h
  58.       int 15h
  59.       mov temp,al;
  60.    end;
  61.    if temp and 16 = 16 then JoyBtn1:=false
  62.       else JoyBtn1:=true;
  63. end;
  64.  
  65. Function JoyBtn2:boolean;
  66. var
  67.    temp:byte;
  68. begin
  69.    asm
  70.       mov ah,84h
  71.       mov dx,00h
  72.       int 15h
  73.       mov temp,al;
  74.    end;
  75.    if temp and 32 = 32 then JoyBtn2:=false
  76.       else JoyBtn2:=true;
  77. end;
  78.  
  79. Procedure JoyCalibrate;
  80.  
  81. begin
  82.  
  83.    writeln('Move Joystick to upper-left, and press a button...');
  84.    repeat
  85.       x1:=JoyX;
  86.       y1:=JoyY;
  87.    until JoyBtn1 or JoyBtn2;
  88.    repeat until not JoyBtn1 or JoyBtn2;
  89.    writeln('Move Joystick to lower-right, and press a button...');
  90.    repeat
  91.       x2:=JoyX;
  92.       y2:=JoyY;
  93.    until JoyBtn1 or JoyBtn2;
  94.  
  95. end;
  96.  
  97. begin
  98.  
  99.    clrscr;
  100.    if not joyexist then begin
  101.       writeln('No joystick');
  102.       halt;
  103.    end;
  104.    joycalibrate;
  105.    write(#10#13,'Range is from (',x1,',',y1,') to (',x2,',',y2,')');
  106.    ch:=readkey;
  107. end.
  108.  
  109.